#include "BitMask.h"

BitMask::BitMask() {}
BitMask::~BitMask() {}
BitMask::BitMask(unsigned int m) {
    mask = m;
}

bool BitMask::moduleEnable(int index) {
    mask |= (1 << index);
}

bool BitMask::moduleDisable(int index) {
    mask &= ~(1 << index);
}

void BitMask::printModuleSwitchInfo() {
    std::bitset<sizeof(mask) * 8> bits(mask);
    // printf("Bitmask:%o\n", bits);
    std::string binaryStr = bits.to_string();

    // 截取后11位
    std::string last11Bits = binaryStr.substr(binaryStr.length() - 11);
    std::cout << "Bitmask: " << last11Bits << std::endl;
}

bool BitMask::checkSwitchStatus(int index) {
    return (mask & (1 << index)) != 0;
}